package com.purchase.ml.mapper.prod;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.purchase.ml.entity.prod.SysProduct;
import com.purchase.ml.entity.prod.SysProductSku;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author :zxm
 * @date :2021/2/25 18:57
 * @description :some description
 **/

@Mapper
@Repository
public interface SysProdSkuMapper extends BaseMapper<SysProductSku> {

    /**
     * 全查询sku
     */
    List<SysProductSku> selectSkuList(Long productId);

    SysProductSku selectProductSkuByProductId(@Param("productId") Long productId);

    @Update("update sys_product_sku set stock=stock-#{quantity} where product_id=#{productId} ")
    int reduceSysProductStock(@Param("productId") Long productId,@Param("quantity") Integer quantity);
}
